package com.hans.myscanner.Scanner.Activity;



import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.hans.myscanner.HansPerference;
import com.hans.myscanner.R;
import com.hans.switchbutton.SwitchButton;

public class SettingsSubActivity extends BaseSubActivity {
    SwitchButton soundSwitch,vibrateSwitch;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings);
        findView();
        initView();
    }

    @Override
    protected void findView() {
        soundSwitch= (SwitchButton) findViewById(R.id.sound_switcher);
        vibrateSwitch= (SwitchButton) findViewById(R.id.vibrate_switcher);
    }

    @Override
    protected void initView() {
        soundSwitch.setOnCheckChangeListener(onCheckChangeListener);
        vibrateSwitch.setOnCheckChangeListener(onCheckChangeListener);
    }
    private SwitchButton.OnCheckChangeListener onCheckChangeListener = new SwitchButton.OnCheckChangeListener() {
        @Override
        public void OnCheck(SwitchButton switchButton, boolean isChecked) {
            switch(switchButton.getId()){
                case R.id.sound_switcher:
                    HansPerference.getInstance(SettingsSubActivity.this).setIsSoundOn(isChecked);
                    break;

                case R.id.vibrate_switcher:
                    HansPerference.getInstance(SettingsSubActivity.this).setIsVibrateOn(isChecked);
                    break;
            }
        }
    };
}
